/*
 * @Author: your name
 * @Date: 2022-03-25 10:07:11
 * @LastEditTime: 2022-04-20 20:01:25
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \mallAdmin\src\app\main\recharge\order\recharge-order.service.ts
 */
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class RechargeOrderService {

  serviceUrls = {
    queryRechargeOrderListUrl: '/recharge/order/list', // 充值专区订单管理--列表
    queryRechargeOrderDetailUrl: '/recharge/order/info', // 充值专区订单管理--详情
    rechargeRefundUrl: '/recharge/order/refund', // 售后退款

    queryRechargeFollowListUrl: '/jc/order/follow', // 跟进list
    cancelOrderItemUrl: '/recharge/order/cancel', // 充值专区订单管理-取消订单
    exportRechargeOrderUrl: '/recharge/order/export', // 充值专区订单管理-导出

    rechargeGoodsListUrl: '/rechargeGoodsType/goodsList', // 充值专区--查询商品
    rechargeBrandListUrl: '/rechargeGoodsType/list', // 充值专区--查询商品品牌
  }

  constructor(public httpClient: HttpClient) {}

  // 充值专区订单管理--列表
  queryRechargeOrderList(params: any) {
    return this.httpClient.get(this.serviceUrls.queryRechargeOrderListUrl, { params }).toPromise();
  }

  // 充值专区订单管理--详情
  queryRechargeOrderDetail(params: any) {
    let url = `${this.serviceUrls.queryRechargeOrderDetailUrl}/${params.id}`;
    return this.httpClient.get(url).toPromise();
  }
  
  // 售后退款
  rechargeRefundData(params: any) {
    return this.httpClient.post(this.serviceUrls.rechargeRefundUrl, params).toPromise();
  }

  // 查询跟进信息
  queryRechargeFollowList(params: any) {
    return this.httpClient.get(this.serviceUrls.queryRechargeFollowListUrl, { params }).toPromise();
  }

  // 充值订单-取消订单
  cancelRechargeOrder(params: any) {
    return this.httpClient.post(this.serviceUrls.cancelOrderItemUrl, params).toPromise();
  }
  
  // 充值订单-导出
  exportRechargeOrder(params: any) {
    return this.httpClient.get(this.serviceUrls.exportRechargeOrderUrl, { params, responseType: 'blob' }).toPromise();
  }

  // 充值专区--查询商品品牌
  getrechargeBrandList() {
    return this.httpClient.post(this.serviceUrls.rechargeBrandListUrl, {}).toPromise();
  }

  // 充值专区--查询商品
  getRechargeGoodsList(id: number) {
    return this.httpClient.post(this.serviceUrls.rechargeGoodsListUrl, {id}).toPromise();
  }
}



